home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Utilities / Converters / Convert_MacPaint / Source / shared.subproj / File.h < prev    next >
Text File  |  1995-06-12  |  5KB  |  158 lines

  1. /***********************************************************************\
  2. Common class for accessing files in all Convert programs
  3. Copyright (C) 1993 David John Burrowes
  4.  
  5. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version.
  6.  
  7. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  8.  
  9. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  10.  
  11. The author, David John Burrowes, can be reached at:
  12.     davidjohn@kira.net.netcom.com
  13.     David John Burrowes
  14.     1926 Ivy #10
  15.     San Mateo, CA 94403-1367
  16. \***********************************************************************/
  17.  
  18. /*
  19. ====================================================================
  20. This is the interface file for the File class.  Full documentation for this class can be found in the File.rtf file.  I will not duplicate all that fine information here.
  21.     This is $Revision: 1.6 $ of this file
  22.     It was last modified by $Author: death $ on $Date: 93/04/04 23:44:23 $
  23. Note that this file was created while using the New Century Schoolbook Roman typeface.  You may find that some things line up strangely if you don't use that family.
  24.  *$Log:    File.h,v $
  25.  * Revision 1.6  93/04/04  23:44:23  death
  26.  * Sun Apr  4 23:44:23 PDT 1993
  27.  * 
  28.  * Revision 1.5  93/01/10  15:07:53  death
  29.  * Sun Jan 10 15:07:52 PST 1993
  30.  * 
  31.  * Revision 1.4  92/07/26  13:57:52  death
  32.  * Update so all works with the font converter...
  33.  * 
  34.  * Revision 1.2  92/04/05  22:51:05  death
  35.  * Miscelaneous revisions.  This is the last version of  version 1.
  36.  * 
  37.  * Revision 1.1  92/03/29  12:18:23  death
  38.  * Initial revision
  39.  * 
  40.  *====================================================================
  41.  */
  42.  
  43. //
  44. // Import our parent class' definition
  45. //
  46. #import "ResultObject.h"
  47. #import "common.h"
  48. //
  49. //    For stat info...
  50. //
  51. #include <sys/types.h>
  52. #include <sys/stat.h>
  53.  
  54. //
  55. // Define types for positions in the underlying file.
  56. //
  57. typedef    PositiveInteger    FilePos;
  58. typedef    FilePos            FilePosDelta;
  59. typedef    Integer            AccessType;
  60.  
  61. //
  62. //
  63. #define    fileAtEOF                1
  64. #define    fileAtStart                2
  65. #define    fileInMiddle                3
  66.  
  67. //
  68. // Now, define our interface.   Again, see the File.rtf document for general info.
  69. //
  70. @interface File:ResultObject
  71. {
  72.     CString        FileName;
  73.     AccessType    AccessMode;
  74.     NXStream*    TheFile;
  75.     ino_t        TheInode;
  76.     Integer        FileLocation;
  77.     Boolean        FileIsOpen;
  78. }
  79.     
  80. - initAndUse:(roCString) pathname;
  81. - initAndUseTemporary;
  82. - CreateAndOpenFor: (AccessType) access;
  83. - OpenExistingFor: (AccessType) access;
  84. - ClearAndOpenExistingFor: (AccessType) access;
  85. - ClearAndOpenFor: (AccessType) access;
  86. - OpenFor: (AccessType) access;
  87. - OpenWithAccess: (Integer) operation;
  88. //
  89. - CloseAndDelete;
  90. - Close;
  91. - CloseAndSave;
  92. - free;
  93. //
  94. - AdvanceBytes: (FilePosDelta) byteLoc;
  95. - BackupBytes: (FilePosDelta) byteLoc;
  96. - (CString) GetBasename;
  97. - (FilePos) GetCurrentPosition;
  98. - (CString) GetExtension;
  99. - (CString) GetFilename;
  100. - (CString) GetPathname;
  101. - (CString) GetDirectory;
  102. - MoveTo: (PositiveInteger) byteLoc;
  103. - (Byte) ReadByte;
  104. - Read: (PositiveInteger) numBytes BytesInto: (ByteString) buffer;
  105. - WriteByte: (Byte) theByte;
  106. - Write: (PositiveInteger) numBytes BytesFrom: (ByteString) buffer;
  107. - (PositiveInteger) FileSize;
  108. - FileInfo;
  109. -  (Boolean) SameFileAs: (CString) someOtherFile;
  110. //
  111. //    internal methods
  112. //
  113. -  (CString) GetFullPathFrom: (roCString) pathname;
  114. - ClearFile: (CString) pathname;
  115. - CreateFile: (CString) pathname;
  116. -  (Boolean) FileExists: (CString) pathname;
  117. @end
  118.  
  119.  
  120.  
  121.  
  122. //
  123. // Now, define some constants used by the class to define the kinds of errors that may occurr
  124. //
  125.  
  126.  
  127. #define FILE_READ            0
  128. #define FILE_WRITE            1
  129. #define FILE_READWRITE    2
  130. #define FILE_APPEND        3
  131. #define FILE_NOACCESS        -1
  132. //
  133. //    Error codes  (using 100 to -300)
  134. //
  135. #define    ERR_STRANGEPATH        50
  136. #define    ERR_BADACCESS        -100
  137. #define    ERR_FILENOTOPEN        -120
  138. #define    ERR_CANTOPEN            -105
  139. #define    ERR_CANTDELETE        -106
  140. #define    ERR_FILEREADONLY    -150
  141. #define    ERR_FILEWRITEONLY    -151
  142. #define    ERR_FILEAPPENDONLY    -152
  143. #define    ERR_NOSUCHFILE        -160
  144. #define    ERR_CREATEFAIL        -170
  145. #define    ERR_FILEEXISTS        -171
  146. #define    ERR_SOMEFILEOPEN    -172
  147. #define    ERR_FILEDOESNTEXIST    -173
  148. #define    ERR_CLEARFAIL        -174
  149. #define    ERR_WRITINGERROR    -200
  150. #define    ERR_FLUSHINGERROR    -201
  151. #define    ERR_WROTEBADCHAR    -202
  152. #define    ERR_READINGERROR    -205
  153. #define    ERR_BADBACKUP        -220
  154. #define    ERR_BADADVANCE        -221
  155. #define    ERR_NODIRECTORY        -250
  156. #define    ERR_CANTGETINFO        -275
  157. #define    ERR_EOF                -225
  158.